package com.taobao.txc.common.config;

import com.alibaba.fastjson.JSON;
import com.taobao.txc.common.LoggerWrap;
import com.taobao.txc.common.util.b.e;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;

class b
  implements Runnable
{
  b(ConsoleConfig paramConsoleConfig) {}
  
  public void run()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    try
    {
      if (ConsoleConfig.a(this.a).size() > 0)
      {
        localStringBuilder.append(ConsoleConfig.b(this.a)).append("/cs/api/config.json");
        HashMap localHashMap1 = new HashMap();
        localHashMap1.put("timeout", ConsoleConfig.c());
        localHashMap1.put("keys", this.a.a(ConsoleConfig.a(this.a).keySet()));
        localObject1 = com.taobao.txc.common.util.b.b.a(localStringBuilder.toString(), null, JSON.toJSONString(localHashMap1));
        if (!StringUtils.isEmpty((String)localObject1)) {
          this.a.a(StringUtils.trim((String)localObject1));
        }
      }
    }
    catch (IOException localIOException)
    {
      Object localObject1;
      ConsoleConfig.d().a(com.taobao.txc.common.b.b.o.be, String.format("POST keys:%s", new Object[] { ConsoleConfig.a(this.a).keySet() }), localIOException);
      try
      {
        localObject1 = new HashMap();
        HashMap localHashMap2 = new HashMap();
        Iterator localIterator1 = ConsoleConfig.a(this.a).keySet().iterator();
        while (localIterator1.hasNext())
        {
          ConsoleConfig.KeyItem localKeyItem = (ConsoleConfig.KeyItem)localIterator1.next();
          String str = null;
          boolean bool = false;
          if (!ConsoleConfig.c(this.a).containsKey(localKeyItem)) {
            synchronized (ConsoleConfig.c(this.a))
            {
              if (!ConsoleConfig.c(this.a).containsKey(localKeyItem))
              {
                str = StringUtils.trim(e.a(localKeyItem.group, localKeyItem.dataId));
                ConsoleConfig.d().info(String.format("POST loadCache dataId:%s group:%s value:%s", new Object[] { localKeyItem.dataId, localKeyItem.group, str }));
                if (!StringUtils.isEmpty(str))
                {
                  ConsoleConfig.c(this.a).put(localKeyItem, str);
                  bool = ConsoleConfig.a(this.a, (Map)localObject1, localHashMap2, localKeyItem.group, localKeyItem.dataId, str);
                }
              }
            }
          } else {
            if ((StringUtils.isEmpty(str)) || (StringUtils.equals((String)ConsoleConfig.c(this.a).get(localKeyItem), str))) {
              continue;
            }
          }
          if ((!bool) && (str != null))
          {
            ??? = (Set)ConsoleConfig.a(this.a).get(localKeyItem);
            if (??? != null)
            {
              Iterator localIterator2 = ((Set)???).iterator();
              while (localIterator2.hasNext())
              {
                n localn = (n)localIterator2.next();
                try
                {
                  localn.a(str);
                }
                catch (Exception localException3) {}
              }
            }
          }
        }
        if ((!((Map)localObject1).isEmpty()) || (!localHashMap2.isEmpty())) {
          ConsoleConfig.a(this.a, (Map)localObject1, localHashMap2);
        }
      }
      catch (Exception localException2)
      {
        ConsoleConfig.d().a(com.taobao.txc.common.b.b.bc, localException2);
      }
      try
      {
        Thread.sleep(ConsoleConfig.e());
      }
      catch (InterruptedException localInterruptedException) {}
    }
    catch (Exception localException1)
    {
      ConsoleConfig.d().a(com.taobao.txc.common.b.b.bc, localException1);
    }
  }
}


/* Location:           C:\Users\ibm\Downloads\txc-yun-sample (1)\txc-yun-sample\lib\txc-client-2.0.72.jar
 * Qualified Name:     com.taobao.txc.common.config.b
 * JD-Core Version:    0.7.0.1
 */